package com.geovis.emergency.spd.biz.system.service.impl;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.IterUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.geovis.common.core.constant.CommonConstants;
import com.geovis.common.core.util.WebUtil;
import com.geovis.common.mybatis.page.PageParam;
import com.geovis.common.mybatis.page.PageResult;
import com.geovis.emergency.spd.biz.system.mapper.SystemResourcesMapper;
import com.geovis.emergency.spd.biz.system.service.ISystemResourcesService;
import com.geovis.emergency.spd.biz.system.service.ISystemRoleResourcesService;
import com.geovis.emergency.spd.entity.system.entity.SystemResources;
import com.geovis.emergency.spd.entity.system.entity.SystemRoleResources;
import com.geovis.emergency.spd.entity.system.pojo.constant.SystemConstant;
import com.geovis.emergency.spd.entity.system.pojo.dto.SystemResourcesDTO;
import com.geovis.emergency.spd.entity.system.pojo.dto.SystemResourcesQueryDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

/**
 * <p>
 * 系统资源表 服务实现类
 * </p>
 *
 * @author 王响
 * @since 2020-07-27
 */
@Service
@AllArgsConstructor
@Slf4j
public class SystemResourcesServiceImpl extends ServiceImpl<SystemResourcesMapper, SystemResources> implements ISystemResourcesService {

    private final ISystemRoleResourcesService systemRoleResourcesService;





    @Override
    @Transactional(rollbackFor = {Exception.class})
    public void removeByIdList(Set<String> idList) {
        if (CollUtil.isEmpty(idList)) {
            return;
        }
        //1、刪除本身
        removeByIds(idList);

        // 2、删除角色资源中间表
        systemRoleResourcesService.remove(Wrappers.lambdaUpdate(SystemRoleResources.class).in(SystemRoleResources::getResourcesId, idList));

    }
}
